package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.AuditStepConfig;

/**
 * 
 * @author 
 *
 */
@DAO
public interface AuditStepConfigDAO{
	
	@SQL("SELECT a.id,a.name,a.stepBegin,a.stepEnd,a.userId,a.deleteFlag,a.createUser,a.createAt,a.updateUser,a.updateAt,b.name as userName FROM AuditStepConfig a left join UserInfo b on a.userId =b.id WHERE a.deleteFlag=1 #if(:t.name!=''){and a.name like '%##(:t.name)%' } ORDER BY a.updateAt DESC LIMIT :t.start,:t.length ")
    List<Map> query(@SQLParam("t") AuditStepConfig auditStepConfig);
	
	@SQL("SELECT count(*) FROM AuditStepConfig WHERE deleteFlag=1 #if(:t.name!=''){and name like '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") AuditStepConfig auditStepConfig);
    
    @SQL("select * from AuditStepConfig where id=:1")
    AuditStepConfig queryById(int id);
    
    @SQL("INSERT INTO AuditStepConfig (name,stepBegin,stepEnd,userId,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.name,:t.stepBegin,:t.stepEnd,:t.userId,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") AuditStepConfig auditStepConfig);
	
	@SQL("UPDATE AuditStepConfig SET name=:t.name,stepBegin=:t.stepBegin,stepEnd=:t.stepEnd,userId=:t.userId,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") AuditStepConfig auditStepConfig);
    
    @SQL("UPDATE AuditStepConfig SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE AuditStepConfig SET userId=:2 WHERE id=:1")
    void updateASPerById(int id,int userId);
}